home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades reversed ƒ / Diagonal fade down-right.c < prev    next >
Text File  |  1994-04-15  |  2KB  |  80 lines

  1. /**********************************************************************\
  2.  
  3. File:        Diagonal fade down-right.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 2
  28. #define theWindowWidth (boundsRect.right-boundsRect.left)
  29. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  30.  
  31. pascal short DiagonalFadeDownRight(Rect boundsRect, Pattern *thePattern);
  32.  
  33. /* If you make a long enough region starting at the top-left corner and
  34.    making a strip up and right of <BoxSize> width, all you have to do is move
  35.    the region down until the entire screen is filled.  Dave thinks ideas like
  36.    this should be taken out and shot, but it works. */
  37.    
  38. pascal short DiagonalFadeDownRight(Rect boundsRect, Pattern *thePattern)
  39. {
  40.     int                maxmax;
  41.     RgnHandle        archie, boundsRgn, sectrgn;
  42.     int                BoxSize;
  43.     Point            zeroPoint;
  44.     
  45.     zeroPoint.h=boundsRect.right;
  46.     zeroPoint.v=boundsRect.bottom;
  47.     
  48.     BoxSize=theWindowWidth/40;
  49.     
  50.     maxmax=(theWindowWidth>theWindowHeight) ? theWindowWidth : theWindowHeight;
  51.     maxmax+=BoxSize;
  52.     boundsRgn=NewRgn();
  53.     RectRgn(boundsRgn, &boundsRect);
  54.     sectrgn=NewRgn();
  55.     archie=NewRgn();
  56.     OpenRgn();
  57.         MoveTo(boundsRect.left-BoxSize, boundsRect.top);
  58.         Line(0,-BoxSize);
  59.         Line(maxmax,-maxmax);
  60.         Line(BoxSize,0);
  61.         Line(-maxmax,maxmax);
  62.     CloseRgn(archie);
  63.  
  64.     do
  65.     {
  66.         StartTiming();
  67.         OffsetRgn(archie,0,BoxSize);
  68.         SectRgn(archie, boundsRgn, sectrgn);
  69.         FillRgn(sectrgn, *thePattern);
  70.         TimeCorrection(CorrectTime);
  71.     }
  72.     while (!PtInRgn(zeroPoint, archie));
  73.     
  74.     DisposeRgn(archie);
  75.     DisposeRgn(boundsRgn);
  76.     DisposeRgn(sectrgn);
  77.     
  78.     return 0;
  79. }
  80.